package cn.big.bigd.biocode.dto;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

/**
 * @ClassName: Result
 * @Description: TODO
 * @Author: FanWang
 * @CreateDate: 2018/1/15 下午4:09
 * @Version: 1.0
 * @Copyright: Copyright (c) 2018/1/15
 **/
@ToString
@Getter
@Setter
public class Result {


	// 响应业务状态   返回码值为0代表返回结果正常，值大于0代表结果异常
    private Integer status;

	// 响应消息
	private String msg;

	// 响应中的数据
	private Object data;
	

	public static Result ok(Object data) {
		return new Result(data);
	}

	public static Result ok() {
		return new Result(null);
	}


	public static Result build(Integer status, String msg, Object data) {
		return new Result(status, msg, data);
	}


	public static Result build(Integer status, String msg) {
		return new Result(status, msg, null);
	}

	public Result(Integer status, String msg, Object data) {
		this.status = status;
		this.msg = msg;
		this.data = data;
	}


	public Result(Object data) {
		this.status = 0; //默认返回正常
		this.msg = "success";
		this.data = data;
	}
	/**
	 * 有参构造
	 * @param data 响应数据
	 */
	public Result(Object data,String msg) {
		this.status = 0; //默认返回正常
		this.msg = msg;
		this.data = data;
	}
	
	/**
	 * 无参构造
	 */
	public Result() {}
	
	


}